<div align="center">
	<table border="0" cellspacing="0" cellpadding="0" width=350>
		<tr>
			<td colspan="5" class="tbltop"><b>&nbsp;<?=$T['Network Tools'];?>&nbsp;</b></td>
		</tr>
	</table>
	<table border="0" cellspacing="0" cellpadding="8" width=350>
		<tr class="row1">
			<td align=center width="25%"><b><? if ($cfg['prog']['traceroute'] != "" || $cfg['remote_network_utils']) { ?><a href='?url=tips&cp=domain&data[tool]=tracert'><? } ?><img border=0 src='icon/tracert.gif'><br><?=$T['Traceroute'];?></a></b></td>
			<td align=center width="25%"><b><? if ($cfg['prog']['ping'] != "" || $cfg['remote_network_utils']) { ?><a href='?url=tips&cp=domain&data[tool]=ping'><? } ?><img border=0 src='icon/ping.gif'><br><?=$T['Ping'];?></a></b></td>
			<td align=center width="25%"><b><? if ($cfg['prog']['whois'] != "" || $cfg['remote_network_utils']) { ?><a href='?url=tips&cp=domain&data[tool]=whois'><? } ?><img border=0 src='icon/whois.gif'><br><?=$T['Whois'];?></a></b></td>
			<td align=center width="25%"><b><? if ($cfg['prog']['dig'] != "" || $cfg['remote_network_utils']) { ?><a href='?url=tips&cp=domain&data[tool]=dig'><? } ?><img border=0 src='icon/whois.gif'><br><?=$T['Dig'];?></a></b></td>
		</tr>
		<tr class="row1">
			<td align=center width="25%"><b><a href='?url=tips&cp=domain&data[tool]=modules'><img border=0 src='icon/modules.gif'><br><?=$T['List Modules'];?></a></b></td>
			<td align=center width="25%"><b><a href='?url=tips&cp=domain&data[tool]=access_log'><img border=0 src='icon/log34.gif'><br><?=$T['Access Log'];?></a></b></td>
			<td align=center width="25%"><b><a href='?url=tips&cp=domain&data[tool]=error_log'><img border=0 src='icon/errorlog34.gif'><br><?=$T['Error Log'];?></a></b></td>
			<td></td>
		</tr>
	</table>
	</div>
	<br>
<?
switch ($data['tool']) {
	case "error_log":
		$logdir = $cfg['webdir']."/".$domaindata["domain"]."/".$domaindata["host"]."/logs";
		if ($cfg['ftpsysname'] == "localhost") {
			$logfile = $logdir."/error";
			$filelocation = tempnam("/tmp", "LOG");
		//	if ($lf = fopen($logfile, "r")) {
		//		while (!feof($lf)) {
		//			$log = fread($lf, 1024);
		//		}
		//		$tf = fopen($filelocation, "w");
		//		fwrite($tf, $log);
			copy($logfile, $filelocation);
			?>
		<div align="center">
		<table border="0" cellspacing="1">
			<tr>
				<td colspan="2" class="tbltop"><b>&nbsp;<?=$T['Error Log'];?>&nbsp;</b></td>
			</tr>
			<tr class="row1">
				<td valign=top><?=$T['File prepared'];?>: <a href='<?=sendfile_url(array('filetype'=>'text/plain', 'filename'=>'error_log.log', 'removefile'=>true, 'filelocation'=>$filelocation));?>'><?=$T['Download'];?></a></td>
			</tr>
		</table>
		</div>
			<?//}
		} else { ?>
			<div align="center">
		<table border="0" cellspacing="1">
			<tr>
				<td colspan="2" class="tbltop"><b>&nbsp;<?=$T['Error Log'];?>&nbsp;</b></td>
			</tr>
			<tr class="row1">
				<td valign="top"><?=$T['Please login via FTP and download this file from the logs directory.'];?></td>
			</tr>
		</table>
		</div>
		<? }
		break;
	case "access_log":
		$logdir = $cfg['webdir']."/".$domaindata["domain"]."/".$domaindata["host"]."/logs";
		if ($cfg['ftpsysname'] == "localhost") {
			$logfile = $logdir."/access";
			$filelocation = tempnam("/tmp", "LOG");
		//	if ($lf = fopen($logfile, "r")) {
		//		while (!feof($lf)) {
		//			$log = fread($lf, 1024);
		//		}
		//		$tf = fopen($filelocation, "w");
		//		fwrite($tf, $log);
			copy($logfile, $filelocation);
			?>
		<div align="center">
		<table border="0" cellspacing="1">
			<tr>
				<td colspan="2" class="tbltop"><b>&nbsp;<?=$T['Access Log'];?>&nbsp;</b></td>
			</tr>
			<tr class="row1">
				<td valign="top"><?=$T['File prepared'];?>: <a href="<?=sendfile_url(array('filetype'=>'text/plain', 'filename'=>'error_log.log', 'removefile'=>true, 'filelocation'=>$filelocation));?>"><?=$T['Download'];?></a></td>
			</tr>
		</table>
		</div>
			<?//}
		} else { ?>
			<div align="center">
		<table border="0" cellspacing="1">
			<tr>
				<td colspan="2" class="tbltop"><b>&nbsp;<?=$T['Access Log'];?>&nbsp;</b></td>
			</tr>
			<tr class="row1">
				<td valign=top><?=$T['Please login via FTP and download this file from the logs directory.'];?></td>
			</tr>
		</table>
		</div>
		<? }
		break;
	case "tracert": ?>
		<div align="center">
		<form action="<?=$current_url;?>" method="post" name="webcp" onSubmit="submitonce(this);">
		<input type=hidden name=data[tool] value='tracert'>
		<table border="0" cellspacing="1">
			<tr>
				<td colspan="2" class="tbltop"><b>&nbsp;<?=$T['Traceroute'];?>&nbsp;</b></td>
			</tr>
			<tr class="row1">
				<td valign=top><input type=textbox name=data[destination]><br>(<?=$T['enter IP address or URL'];?>)</td>
				<td valign=top><input type=submit value="<?=$T['Begin Traceroute'];?>"></td>
			</tr>
		</table>
		</div>
		<? if ($data['destination'] != "") {
			$data['destination'] = preg_replace("%[^0-9a-zA-Z\.\-]%", "", $data['destination']);
		?>
		<br>
		<div align="center">
		<table border="0" width=650 cellpadding=0 cellspacing=0>
			<tr>
				<td colspan="1" class="tbltop"><b>&nbsp;<?=$T['Performing traceroute to '];?><?=$data['destination'];?>...&nbsp;</b></td>
			</tr>
		</table>
		<?
		flush();
		?>
		<table border="0" width=650 cellpadding=0 cellspacing=0>
			<tr class="row1">
<? if ($cfg['remote_network_utils']) { ?>
<td>
<script language="javascript" type="text/javascript">
                //onload = iFrameHeight;
                function iFrameHeight() {
                        var h = 0;
                        if ( !document.all ) {
                                h = document.getElementById('blockrandom').contentDocument.height;
                                document.getElementById('blockrandom').style.height = h + 60 + 'px';
                        } else if( document.all ) {
                                h = document.frames('blockrandom').document.body.scrollHeight;
                                document.all.blockrandom.style.height = h + 20 + 'px';
                        }
                }
                </script>
                <iframe
                onload="iFrameHeight()"
                id="blockrandom"
                src="http://www.dnsstuff.com/tools/tracert.ch?ip=<?php echo $data['destination']; ?>"
                width="100%"
                height="600"
                scrolling="auto"
                align="top"
                frameborder="0"
                class="wrapper">
                This option will not work correctly.  Unfortunately, your browser does not support Inline Frames                </iframe>
</td>
<? } else { ?>
				<td><pre><?
				system ($cfg['prog']['traceroute']." ".$data['destination']);
				?></pre></td>
<? } ?>
			</tr>
		</table>
		</div>
		<? }
		break;
	case "ping": ?>
		<div align="center">
		<form action="<?=$current_url;?>" method="post" name="webcp" onSubmit="submitonce(this);">
		<input type=hidden name=data[tool] value='ping'>
		<table border="0" cellspacing="1">
			<tr>
				<td colspan="2" class="tbltop"><b>&nbsp;<?=$T['Ping'];?>&nbsp;</b></td>
			</tr>
			<tr class="row1">
				<td valign=top><input type=textbox name=data[destination]><br>(<?=$T['enter IP address or URL'];?>)</td>
				<td valign=top><input type=submit value="<?=$T['Begin Ping'];?>"></td>
			</tr>
		</table>
		</div>
		<? if ($data['destination'] != "") {
			$data['destination'] = preg_replace("%[^0-9a-zA-Z\.\-]%", "", $data['destination']);
		?>
		<br>
		<div align="center">
		<table border="0" width=650 cellpadding=0 cellspacing=0>
			<tr>
				<td colspan="1" class="tbltop"><b>&nbsp;<?=$T['Performing ping on '];?><?=$data['destination'];?>...&nbsp;</b></td>
			</tr>
		</table>
		<?
		flush();
		?>
		<table border="0" width=650 cellpadding=0 cellspacing=0>
			<tr class="row1">
<? if ($cfg['remote_network_utils']) { ?>
<td>
<script language="javascript" type="text/javascript">
                //onload = iFrameHeight;
                function iFrameHeight() {
                        var h = 0;
                        if ( !document.all ) {
                                h = document.getElementById('blockrandom').contentDocument.height;
                                document.getElementById('blockrandom').style.height = h + 60 + 'px';
                        } else if( document.all ) {
                                h = document.frames('blockrandom').document.body.scrollHeight;
                                document.all.blockrandom.style.height = h + 20 + 'px';
                        }
                }
                </script>
                <iframe
                onload="iFrameHeight()"
                id="blockrandom"
                src="http://www.dnsstuff.com/tools/ping.ch?ip=<?php echo $data['destination']; ?>"
                width="100%"
                height="600"
                scrolling="auto"
                align="top"
                frameborder="0"
                class="wrapper">
                This option will not work correctly.  Unfortunately, your browser does not support Inline Frames                </iframe>
</td>
<? } else { ?>
				<td><pre><?
				system ($cfg['prog']['ping']." -c 5 ".$data['destination']);
				?></pre></td>
<? } ?>
			</tr>
		</table>
		</div>
		<? }
		break;
	case "whois": ?>
		<div align="center">
		<form action="<?=$current_url;?>" method="post" name="webcp" onSubmit="submitonce(this);">
		<input type=hidden name=data[tool] value='whois'>
		<table border="0" cellspacing="1">
			<tr>
				<td colspan="2" class="tbltop"><b>&nbsp;<?=$T['Whois'];?>&nbsp;</b></td>
			</tr>
			<tr class="row1">
				<td valign=top><input type=textbox name=data[destination]><br>(<?=$T['enter IP address or URL'];?>)</td>
				<td valign=top><input type=submit value="<?=$T['Whois Search'];?>"></td>
			</tr>
		</table>
		</div>
		<? if ($data['destination'] != "") {
			$data['destination'] = preg_replace("%[^0-9a-zA-Z\.\-]%", "", $data['destination']);
		?>
		<br>
		<div align="center">
		<table border="0" width=700 cellpadding=0 cellspacing=0>
			<tr>
				<td colspan="1" class="tbltop"><b>&nbsp;<?=$T['Performing whois on '];?><?=$data['destination'];?>...&nbsp;</b></td>
			</tr>
		</table>
		<?
		flush();
		?>
		<table border="0" width=700 cellpadding=0 cellspacing=0>
			<tr class="row1">
<? if ($cfg['remote_network_utils']) { ?>
<td>
<script language="javascript" type="text/javascript">
                //onload = iFrameHeight;
                function iFrameHeight() {
                        var h = 0;
                        if ( !document.all ) {
                                h = document.getElementById('blockrandom').contentDocument.height;
                                document.getElementById('blockrandom').style.height = h + 60 + 'px';
                        } else if( document.all ) {
                                h = document.frames('blockrandom').document.body.scrollHeight;
                                document.all.blockrandom.style.height = h + 20 + 'px';
                        }
                }
                </script>
                <iframe
                onload="iFrameHeight()"
                id="blockrandom"
                src="http://www.dnsstuff.com/tools/whois.ch?ip=<?php echo $data['destination']; ?>"
                width="100%"
                height="600"
                scrolling="auto"
                align="top"
                frameborder="0"
                class="wrapper">
                This option will not work correctly.  Unfortunately, your browser does not support Inline Frames                </iframe>
</td>
<? } else { ?>
				<td><pre><?
				system ($cfg['prog']['whois']." ".$data['destination']);
				?></pre></td>
<? } ?>
			</tr>
		</table>
		</div>
		<? }
		break;
	case "dig": ?>
		<div align="center">
		<form action="<?=$current_url;?>" method="post" name="webcp" onSubmit="submitonce(this);">
		<input type=hidden name=data[tool] value='dig'>
		<table border="0" cellspacing="1">
			<tr>
				<td colspan="2" class="tbltop"><b>&nbsp;<?=$T['Dig'];?>&nbsp;</b></td>
			</tr>
			<tr class="row1">
				<td valign=top><input type=textbox name=data[destination]><br>(<?=$T['enter IP address or URL'];?>)</td>
				<td valign=top><input type=submit value="<?=$T['Begin Dig'];?>"></td>
			</tr>
		</table>
		</div>
		<? if ($data['destination'] != "") {
			$data['destination'] = preg_replace("%[^0-9a-zA-Z\.\-]%", "", $data['destination']);
		?>
		<br>
		<div align="center">
		<table border="0" width=700 cellpadding=0 cellspacing=0>
			<tr>
				<td colspan="1" class="tbltop"><b>&nbsp;<?=$T['Performing dig on '];?><?=$data['destination'];?>...&nbsp;</b></td>
			</tr>
		</table>
		<?
		flush();
		?>
		<table border="0" width=700 cellpadding=0 cellspacing=0>
			<tr class="row1">
<? if ($cfg['remote_network_utils']) { ?>
<td>
<script language="javascript" type="text/javascript">
                //onload = iFrameHeight;
                function iFrameHeight() {
                        var h = 0;
                        if ( !document.all ) {
                                h = document.getElementById('blockrandom').contentDocument.height;
                                document.getElementById('blockrandom').style.height = h + 60 + 'px';
                        } else if( document.all ) {
                                h = document.frames('blockrandom').document.body.scrollHeight;
                                document.all.blockrandom.style.height = h + 20 + 'px';
                        }
                }
                </script>
                <iframe
                onload="iFrameHeight()"
                id="blockrandom"
                src="http://www.dnsstuff.com/tools/lookup.ch?name=<?php echo $data['destination']; ?>&type=A"
                width="100%"
                height="600"
                scrolling="auto"
                align="top"
                frameborder="0"
                class="wrapper">
                This option will not work correctly.  Unfortunately, your browser does not support Inline Frames                </iframe>
</td>
<? } else { ?>
				<td><pre><?
				system ($cfg['prog']['dig']." ".$data['destination']);
				?></pre></td>
<? } ?>
			</tr>
		</table>
		</div>
		<? }
		break;
	case "modules":
		$ext = $data['ext'];
		?>
		<div align="center">
		<table border="0" width=300 cellpadding=0 cellspacing=0>
			<tr>
				<td colspan="1" class="tbltop"><b>&nbsp;<?=$T['Loaded PHP Extensions'];?>&nbsp;</b></td>
			</tr>
			<tr class="row1">
				<td><?
				$res = get_loaded_extensions();
				sort($res);
				for ($i=0; $i<sizeOf($res); $i++) {
					echo "&nbsp;<a ";
					if ($ext == $res[$i]) { echo " name=funcs "; }
					echo "href='".$current_url."&data[tool]=modules&data[ext]=".$res[$i]."#funcs'>".$res[$i]."</a><br>";
					if ($ext == $res[$i]) {
						echo "<ul>";
						$ext = get_extension_funcs($res[$i]);
						for ($j=0; $j<sizeOf($ext); $j++) {
							echo $ext[$j]."<br>";
						}
						echo "</ul>";
					}
				}
				?></td>
			</tr>
		</table>
		<br>
		<? if (function_exists('apache_get_modules')) { ?>
		<table border="0" width=300 cellpadding=0 cellspacing=0>
			<tr>
				<td colspan="1" class="tbltop"><b>&nbsp;<?=$T['Loaded Apache Modules'];?>&nbsp;</b></td>
			</tr>
			<tr class="row1">
				<td><?

				$res = apache_get_modules();
				sort($res);
				for ($i=0; $i<sizeOf($res); $i++) {
					echo "&nbsp;".$res[$i]."<br>";
				}
				?></td>
			</tr>
		</table>
		<br>
		<? } ?>
		<table border="0" width=300 cellpadding=0 cellspacing=0>
			<tr>
				<td colspan="1" class="tbltop"><b>&nbsp;<?=$T['Installed Perl Modules'];?>&nbsp;</b></td>
			</tr>
			<tr class="row1">
				<td><?
				$res = explode("|", exec("./listpm.pl"));
				if (sizeOf($res) >= 1) {
					sort($res);
					for ($i=0; $i<sizeOf($res); $i++) {
						if ($res[$i] != "") {
							echo "&nbsp;".$res[$i]."<br>";
						}
					}
				} else {
					echo "None Found";
				}
				?></td>
			</tr>
		</table>
		<br>
		</div>
		<?
		break;
}
?>

